/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.oea.struts.actions;

import com.oea.hibernate.entities.Teaching_Scheme;
import com.oea.struts.forms.AddTeachingSchemeForm;
import java.io.PrintWriter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author DELL
 */
public class AddTeachingSchemeAction extends org.apache.struts.action.Action {

    /* forward name="success" path="" */
    private static  String path = "success";

    /**
     * This is the action called from the Struts framework.
     *
     * @param mapping The ActionMapping used to select this instance.
     * @param form The optional ActionForm bean for this request.
     * @param request The HTTP Request we are processing.
     * @param response The HTTP Response we are processing.
     * @throws java.lang.Exception
     * @return
     */
    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        
        AddTeachingSchemeForm atsf=(AddTeachingSchemeForm)form;
        Teaching_Scheme ts=new Teaching_Scheme();
         
         ts.setBranch(atsf.getBranch());
         ts.setSemester(atsf.getSemester());
         ts.setDivision(atsf.getDivision());
         ts.setSubcode(atsf.getSubcode());
         ts.setSubname(atsf.getSubname());
         ts.setTheoryhours(atsf.getTheoryhours());
         ts.setPracticalhours(atsf.getPracticalhours());
         ts.setTutorialhours(atsf.getTutorialhours());
          ts.setCredit(atsf.getCredit());
          ts=(Teaching_Scheme)ts.add();
         
        if(ts!=null){
            path="add_teaching_scheme";
        }
        return mapping.findForward(path);
    }
}
